package com.shyt.util;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class ApiResponse<T> {
    private String code;
    private String msg;
    private T data;

    public static <T> ApiResponse<T> ok(T data) {
        return new ApiResponse("200", "调用成功", data);
    }

    public static <T> ApiResponse<T> erro(String erroCode) {
        return new ApiResponse(erroCode, "调用失败", "");
    }

    public static <T> ApiResponse<T> erro(String erroCode, String msg) {
        return new ApiResponse(erroCode, msg, "");
    }

    public static <T> ApiResponse<T> erro(String erroCode, String msg, T data) {
        return new ApiResponse(erroCode, msg, data);
    }
}
